package com.px.service;

import com.px.mapper.CollectionDao;
import com.px.pojo.ShCollection;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class CollectionServiceProviderImpl implements CollectionServiceProvider {

    @Resource
    private CollectionDao collectionDao;
    @Override
    public boolean insertCollection(ShCollection collection) throws Exception {
        int result = collectionDao.insert(collection);
        if(result > 0){
            return true;
        }
        return false;
    }

    @Override
    public boolean deleteById(Integer id) throws Exception {
        int result = collectionDao.deleteById(id);
        if (result > 0) {
            return true;
        }
        return false;
    }

    @Override
    public ShCollection findCollection(Integer commodityId) throws Exception {
        return collectionDao.getCollectionByCommodityId(commodityId);
    }

    @Override
    public boolean updateCollection(ShCollection shCollection) throws Exception {
        int result = collectionDao.update(shCollection);
        if (result > 0) {
            return true;
        }
        return false;
    }
}
